package com.qingcheng.consumer;

import com.qingcheng.service.order.OrderService;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;
import org.springframework.beans.factory.annotation.Autowired;

public class PayOrderMessageListener implements MessageListener {

    @Autowired
    private OrderService orderService;

    /**
     * 支付 延迟信息
     * @param message
     */
    @Override
    public void onMessage(Message message) {
        try {
            //在发送延迟消息之后，如果用户已经支付，数据库会改变支付状态，还有流水号，订单状态也会改变
            //查询订单 支付状态，调用 微信api，查看信息，如果没有支付，就调用 关闭api
            String orderId = new String(message.getBody());//id
            orderService.overtimeOrder(orderId);

        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("异常");
        }
    }
}
